import {
  Entity,
  PrimaryGeneratedColumn,
  ManyToOne,
  CreateDateColumn,
  JoinColumn,
} from 'typeorm';
import { Favorite } from './favorite.entity';
import { Video } from './video.entity';

@Entity('favorite_videos')
export class FavoriteVideo {
  @PrimaryGeneratedColumn()
  id: number;

  @ManyToOne(() => Favorite, (favorite) => favorite.favoriteVideos)
  @JoinColumn({ name: 'favorite_id' })
  favorite: Favorite;

  @ManyToOne(() => Video)
  @JoinColumn({ name: 'video_id' })
  video: Video;

  @CreateDateColumn({
    type: 'datetime',
    comment: '收藏时间',
  })
  created_at: Date;
}
